//package com.shuai.jit.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//
//import javax.servlet.Filter;
//import javax.servlet.FilterChain;
//import javax.servlet.FilterConfig;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.OutputStream;
//
//@Component
//@Slf4j
//public class OriginFilter implements Filter {
//
//
//    @Override
//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain arg2)
//            throws IOException, ServletException {
//        HttpServletResponse response = (HttpServletResponse) res;
//        HttpServletRequest request = (HttpServletRequest) req;
//        if (request.getMethod().equals("OPTIONS")) {
//            response.setStatus(HttpServletResponse.SC_OK);
//        }
//
//        String origin = request.getHeader("Origin");
//        // 浏览器 跨域 请求  Access-Control-Allow-Credentials 要设置为true 允许客户端携带跨域cookie，  Access-Control-Allow-Origin 此时 origin值不能为“*”，只能为指定单一域名
//        //response.setH    eader("Access-Control-Allow-Origin", "http://ailer.oicp.io");
//        response.setHeader("Access-Control-Allow-Origin", "*");// 允许指定域访问跨域资源
//        //是否允许cookie
//        //response.setHeader("Access-Control-Allow-Credentials", "true");     //
//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT");
//        response.setHeader("Access-Control-Max-Age", "18000");//Access-Control-Max-Age用来指定本次预检请求的有效期，单位为秒，，在此期间不用发出另一条预检请求。
//        response.setHeader("Access-Control-Allow-Headers", "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization");
//        response.setHeader("Access-Control-Expose-Headers", "*");//响应客户端的头部 允许携带Token 等等
//        response.setContentType("application/json; charset=utf-8");
//        response.setCharacterEncoding("UTF-8");
//        log.info("允许跨域");
//        arg2.doFilter(req, res);
//
//    }
//
//
//    @Override
//    public void destroy() {
//        // TODO Auto-generated method stub
//
//    }
//
//
//    @Override
//    public void init(FilterConfig arg0) throws ServletException {
//        // TODO Auto-generated method stub
//
//    }
//
//}